﻿using System.Collections.Generic;

namespace LeRenard
{
    /// <summary>
    /// Provides extension methods to interact with <see cref="IRange"/> of "T" objects.
    /// </summary>
    public static class IRangeExtensions
    {
        /// <summary>
        /// Lists all values of an <see cref="IRange"/> of <see cref="int"/> in an <see cref="IEnumerable"/>.
        /// </summary>
        /// <returns>An <see cref="IEnumerable"/> of <see cref="int"> containing all elements within this specified range.</returns>
        public static IEnumerable<int> AsEnumerable(this IRange<int> range)
        {
            var numbers = new List<int>();
            for (int i = range.Minimum; i <= range.Maximum; i++)
            {
                numbers.Add(i);
            }

            return numbers;
        }
    }
}